﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BCDataCenter.BOL;

public partial class WebMaster_Print : System.Web.UI.Page
{
    string error = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        Printed();        
            
    }
    private void Printed()
    {
        if ((Session["SoChungTu"] != null) && (Session["LoaiNghiepVu"] != null) && (Session["TenLoaiNghiepVu"] != null) && (Session["Sitecode"] != null))
        {
            if (Session["LoaiNghiepVu"].ToString() == "F")
            {
                gvListChiTietNghiepVuIn.Columns[2].Visible = true;
                gvListChiTietNghiepVuIn.Columns[3].Visible = true;
                gvListChiTietNghiepVuIn.Columns[4].Visible = false;
                pnlNVDieuChinhGia_F.Visible = true;
                pnlNhapHangVe_R.Visible = false;
                ShowDataPrint();
            }
            else if (Session["LoaiNghiepVu"].ToString() == "R")
            {
                gvListChiTietNghiepVuIn.Columns[2].Visible = false;
                gvListChiTietNghiepVuIn.Columns[3].Visible = false;
                gvListChiTietNghiepVuIn.Columns[4].Visible = true;
                pnlNVDieuChinhGia_F.Visible = false;
                pnlNhapHangVe_R.Visible = true;
                ShowDataPrint();
            }
            else if (Session["LoaiNghiepVu"].ToString() == "T")
            {
                gvListChiTietNghiepVuIn.Columns[2].Visible = false;
                gvListChiTietNghiepVuIn.Columns[3].Visible = false;
                gvListChiTietNghiepVuIn.Columns[4].Visible = true;
                pnlNVDieuChinhGia_F.Visible = false;
                pnlNhapHangVe_R.Visible = true;
                ShowDataPrint();
            }
        }
        else
        {
            return;
        }        
    }

    private void ShowDataPrint()
    {
        try
        {
            BWInCacNghiepVuKho obj = new BWInCacNghiepVuKho();
            lblSoChungTu.Text = Session["SoChungTu"].ToString();
            lbTitlePrint.Text = Session["TenLoaiNghiepVu"].ToString();
            DataSet ds = new DataSet();
            //Trung Tam PP
            ds = obj.GetTrungTamPP(ref error, Session["Sitecode"].ToString());
            lblTrungTamPP.Text = ds.Tables[0].Rows[0]["sitename"].ToString();
            lblDiaChi.Text = ds.Tables[0].Rows[0]["Address"].ToString();
            lblTelFax.Text = ds.Tables[0].Rows[0]["TelFax"].ToString();
            
            //Nghiep Vụ In
            ds = obj.GetListChiTietNghiepVuCanIn(ref error, Session["LoaiNghiepVu"].ToString(), Session["SoChungTu"].ToString());
            gvListChiTietNghiepVuIn.DataSource = ds;
            gvListChiTietNghiepVuIn.DataBind();
            lblNgayChungTu.Text = ds.Tables[0].Rows[0]["NgayChungTu"].ToString();
            lblGioNghiepVu.Text = ds.Tables[0].Rows[0]["ThoiGian"].ToString();
            lblNguoiDieuChinh.Text = ds.Tables[0].Rows[0]["NguoiTao"].ToString();
            PrintHelper.PrintWebControl(pnlPrintDoiGiaBanChuan);
        }
        catch
        {

        }    
    }
}
